package com.example.demo1102.demo4;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorTest {
    public static void main(String[] args) {

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,5,10,
                TimeUnit.SECONDS,new LinkedBlockingQueue(4));
        for (int i = 0; i < 20; i++) {
            final int a=i;
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"======="+a);
                }
            });
        }
    }
}
